Skip to content

clean now runs after all SpotlessTask. Fixes #159. - #160

Merged
nedtwigg merged 3 commits into
masterfrom
cleanAfterSpotless
Oct 31, 2017
Merged

nedtwigg merged 3 commits into
masterfrom
cleanAfterSpotless

Conversation

@nedtwigg

Copy link
Copy Markdown
Member

No description provided.

.matching(task -> task.getName().equals("clean"))
.all(task -> task.doLast(unused -> SpotlessCache.clear()));
.matching(task -> task instanceof SpotlessTask)
.all(task -> clean.mustRunAfter(task));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nedtwigg IIUC from what you said at #159 (comment), this line ought to be, .all(task -> task.mustRunAfter(clean)). Have I misunderstood something here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also unclear to me if clean.mustRunAfter(task) forces clean to run regardless of whether or not a user requested it on top of spotless{Apply,Check}.

In other words, do ./gradlew spotlessCheck and ./gradlew {clean} spotlessCheck {clean} do the same thing now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mustRunAfter is not the same as dependsOn

this line ought to be, .all(task -> task.mustRunAfter(clean))

Good catch! When I wrote this code, I meant for the order to be spotless then clean, but that's silly. "Run the compiler, then clean the output". lol. I'll push a fix.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mustRunAfter is not the same as dependsOn

Cool! Thanks for the clarification.

Good catch!

You're very welcome!

When I wrote this code, I meant for the order to be spotless then clean, but that's silly. "Run the compiler, then clean the output". lol. I'll push a fix.

haha, SGTM. :)

.matching(task -> task.getName().equals("clean"))
.all(task -> task.doLast(unused -> SpotlessCache.clear()));
.matching(task -> task instanceof SpotlessTask)
.all(task -> task.mustRunAfter(clean));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gradle has a method (at least in the newer versions) that's something like:

project.getTasks().withType(SpotlessTask.class).all(task -> task.mustRunAfter(clean));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

@nedtwigg

Copy link
Copy Markdown
Member Author

Unless there are objections, I'm gonna merge in an hour, so that @JLLeitschuh can do an integration test on 3.7.0-SNAPSHOT and make sure #159 is solved for him.

@JLLeitschuh JLLeitschuh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. If you can add a test that would be good. But if not, this is fine as is.

@nedtwigg
nedtwigg merged commit e3556dd into master Oct 31, 2017
@nedtwigg
nedtwigg deleted the cleanAfterSpotless branch October 31, 2017 19:10
@nedtwigg

Copy link
Copy Markdown
Member Author

I agree a test would be nice, but I couldn't figure a way to reliably repeat the race condition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants